package com.elitel.frame.base.service.strategy.sql;

import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class ParseSQLFactory {

    private static final Map<Integer, ParseSQLStrategy> STRATEGY_MAP = new HashMap<>();

    public static void register(Integer markType, ParseSQLStrategy strategy) {
        STRATEGY_MAP.put(markType, strategy);
    }

    public static ParseSQLStrategy getStrategyNoNull(Integer markType) {
        ParseSQLStrategy strategy = STRATEGY_MAP.get(Optional.ofNullable(markType).orElse(1));
        Assert.notNull(strategy, "传入参数有误！");
        return strategy;
    }
}
